﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using GraphCompiler.Core.ObjectModel.DiagramModel;

namespace GraphCompiler.Specification.ObjectModel.DiagramModel
{
    public class DiagramSpecs
    {
        [TestFixture]
        public class when_empty
        {
            Diagram _emptyDiagram = new Diagram();
            Diagram _otherEmptyDiagram = new Diagram();

            [Test]
            public void is_equal_to_itself()
            {
                Assert.AreEqual(_emptyDiagram, _emptyDiagram);
            }

            [Test]
            public void is_equal_to_other_empty_diagram()
            {
                Assert.AreEqual(_emptyDiagram, _otherEmptyDiagram);
            }

            [Test]
            public void is_not_equal_to_nonempty_diagram()
            {
                var nonEmptyDiagram = new Diagram();
                nonEmptyDiagram.AddBox(new Box(""));

                Assert.AreNotEqual(_emptyDiagram, nonEmptyDiagram);
            }
        }

        [TestFixture]
        public class when_containing_children
        {
            Diagram _diagram = new Diagram();
            Diagram _diagramWithSameChildren = new Diagram();
            Diagram _diagramWithEqualChildren = new Diagram();
            Diagram _diagramWithOtherChildren = new Diagram();

            [SetUp]
            public void SetUp()
            {
                var box1 = new Box("foo");
                var box2 = new Box("bar");

                _diagram.AddBox(box1);
                _diagram.AddBox(box2);

                _diagramWithSameChildren.AddBox(box1);
                _diagramWithSameChildren.AddBox(box2);

                _diagramWithEqualChildren.AddBox(new Box("foo"));
                _diagramWithEqualChildren.AddBox(new Box("bar"));

                _diagramWithOtherChildren.AddBox(new Box("different name"));
                _diagramWithOtherChildren.AddBox(new Box("different name2"));
            }

            [Test]
            public void is_equal_to_self()
            {
                Assert.AreEqual(_diagram, _diagram);
            }

            [Test]
            public void is_equal_to_diagram_with_same_children()
            {
                Assert.AreEqual(_diagram, _diagramWithSameChildren);
            }

            [Test]
            public void is_equal_to_diagram_with_equal_children()
            {
                Assert.AreEqual(_diagram, _diagramWithEqualChildren);
            }

            [Test]
            public void is_not_equal_to_diagram_with_other_children()
            {
                Assert.AreNotEqual(_diagram, _diagramWithOtherChildren);
            }
        }
    }
}
